<?php
declare(strict_types=1);

/**
 * @fixme 缓存类
 * @author Kong
 * @date 2025-06-07 17:31:20
 * */
namespace App\Utils;


use Hyperf\Context\ApplicationContext;
use function Hyperf\Support\env;

class RedisClient
{
    private static $instance;

    public static function getInstance()
    {
        if (! self::$instance) {
            self::$instance = ApplicationContext::getContainer()->get(\Hyperf\Redis\Redis::class);
            // 主动触发连接初始化
            self::$instance->connect(env("REDIS_HOST"),(int)env("REDIS_PORT"));
            self::$instance->auth(env("REDIS_AUTH"));
            self::$instance->select((int)env("REDIS_DB"));
        }
        return self::$instance;
    }
}
